package model.semantics;

import model.State;

public class IfNode extends Node<Integer> {
    private Node<Integer> myExpr, myIfNode;

    public IfNode(Node<Integer> expr, Node<Integer> ifNode) {
        myExpr = expr;
        myIfNode = ifNode;
    }

    @Override
    public Integer evaluate(State<Integer> state) {
        return myExpr.evaluate(state) > 0 ? myIfNode.evaluate(state) : null;
    }

    @Override
    public String toString() {
        return this.getClass().getName() + " ( " + myExpr.toString() + " ) { "
                + myIfNode.toString() + " }";
    }
}
